#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;

void showVideo(string path){
    namedWindow("Example3",WINDOW_AUTOSIZE);
    VideoCapture cap;
    cap.open(path);
    Mat frame;
    while (true)
    {
        cap>>frame;
        if(frame.empty()){
            break;
        }
        imshow("Example3",frame);
        if(waitKey(33)>=0){
            break;
        }
    }
    
}

void showImage(string path){
    Mat image;
    image = imread( path, IMREAD_COLOR );

    // if ( !image.data )
    // {
    //     return -1;
    // }
    if(image.empty()){
        cout<<"No image data"<<endl;
        return ;
    }
    namedWindow("Display Image", WINDOW_AUTOSIZE );
    imshow("Display Image", image);

    waitKey(0);
}

int main(int argc, char** argv )
{
    if ( argc != 2 )
    {
        cout<<"usage: DisplayImage.out <Image_Path>"<<endl;
        return -1;
    }

    showVideo(string(argv[1]));

    return 0;
}

